package de.tuhh.simsearch.model.persistence.contentmgmt.mltools.interfaces;

import java.io.IOException;
import java.math.BigInteger;
import java.util.List;

import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.tika.exception.TikaException;
import org.xml.sax.SAXException;
import de.tuhh.simsearch.model.persistence.contentmgmt.entities.FileEntity;

/**
 * The IndexerInterface holds functionality to communicate with an indexer. It is possible to create an index, fill it
 * with documents, remove documents for a file and most importantly search within the index.
 * 
 * @author SimSearch 1
 * 
 */
public interface IndexerInterface extends IndexingConstants {

  /**
   * Creates an entry for the file in the index.
   * 
   * @param entity
   *          the entity of the file to index
   * @throws IOException
   * @throws TikaException
   * @throws SAXException
   */
  public void createIndexForFile(FileEntity entity) throws IOException, TikaException, SAXException;

  /**
   * Deletes the entry for this specific file entity
   * 
   * @param entity
   *          the entity to delete
   * @throws IOException
   */
  public void deleteIndexForFile(FileEntity entity) throws IOException;

  /**
   * Searches for a string within all fields of the index.
   * 
   * @param srchStrng
   *          the string to search for
   * @return The sorted list of file ids. Most relevant id at 0
   * @throws IOException
   */
  public List<BigInteger> searchInIndex(String srchStrng) throws IOException, ParseException;

  /**
   * Searches for a string within specified fields within the index.
   * 
   * @param srchStrng
   * @param fields
   *          see {@link IndexingConstants} for list of possible fields
   * @return The sorted list of file ids.
   */
  public List<BigInteger> searchInIndex(String srchStrng, String[] fields) throws IOException, ParseException;
}
